import { message } from 'ant-design-vue'
import axios from 'axios'

let http = axios.create({
  baseURL: window.config.host,
  timeout: 1000
})

http.interceptors.request.use(function (config) {
  return config
}, function (error) {
  return Promise.reject(error)
})

http.interceptors.response.use(function (response) {
  switch (response.data.code) {
    case 402:
      message.error({
        content: response.data.msg
      })
  }
  return response
}, function (error) {
  return Promise.reject(error)
})

export default http